using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;


namespace UglyAnimals
{
    class Animal:Entity
    {
        public enum AnimationState
        {
            Standing,
            Starting,
            Flying,
            Landing,
            Sliding
        };

        public AnimationState currentAnimationState;

        // Animation representing the player 
        public List<Animation> Animations
        {
            get;
            set;
        }

        public float Gravity
        {
            get;
            set;
        }

        public float AirResistance
        {
            get;
            set;
        }

        public float GroundResistance
        {
            get;
            set;
        }

        public float Speed
        {
            get;
            set;
        }

        public float FallingSpeed{
            get; set;
        }

        // Position of the Player relative to the upper left side of the screen
        public override Vector2 Position
        {
            get
            {
                return (Animations.ElementAt((int)currentAnimationState)).Position;
            }

            set
            {
                (Animations.ElementAt((int)currentAnimationState)).Position = value;
            }
        }

        // Get the width of the player      
        public override int Width
        {
            get
            {
                return (Animations.ElementAt((int) currentAnimationState)).FrameWidth;
            }
        }

        // Get the height of the player 
        public override int Height
        {
            get
            {
                return (Animations.ElementAt((int) currentAnimationState)).FrameHeight;
            }
        }


        public void Initialize(List<Animation> animations, Vector2 position, float gravity, float speed, float airResistance, float groundResistance)
        {
            Animations = animations;
            Position = position;
            currentAnimationState = AnimationState.Standing;
            Gravity = gravity;
            AirResistance = airResistance;
            GroundResistance = groundResistance;
            FallingSpeed = Gravity * 4;
            Speed = speed;
            Active = true;
        }

        public override void Update(GameTime gameTime)
        {
            Animations.ElementAt((int)currentAnimationState).Position = Position;
           Animations.ElementAt((int) currentAnimationState).Update(gameTime);
        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            Animations.ElementAt((int)currentAnimationState).Draw(spriteBatch);
        }
    }
}
